/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Loja;

import JPA.Satisfacao;
import java.io.IOException;
import java.rmi.ServerException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author rm64811
 */
@WebServlet(urlPatterns="/processarFormSatisfacao")
public class ProcessarFormSatisfacao extends HttpServlet {
    
    private EntityManagerFactory fabricaEntityManager;
    public void init() throws ServletException{
            fabricaEntityManager = Persistence.createEntityManagerFactory("sistemaWeb");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) 
            throws ServletException, IOException {
        
        Satisfacao satisfacao=new Satisfacao();
        satisfacao.setNome(req.getParameter("nome"));
        satisfacao.setComentario(req.getParameter("comentario"));
        EntityManager motor=fabricaEntityManager.createEntityManager();
        motor.getTransaction().begin();
        motor.persist(satisfacao);
        motor.getTransaction().commit();
    }
}
